<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>作者列表</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        h1 {
            color: #333;
        }
        .add-button {
            display: inline-block;
            background-color: #4CAF50;
            color: white;
            padding: 10px 20px;
            text-decoration: none;
            border-radius: 4px;
            margin-bottom: 20px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
        }
        th, td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }
        th {
            background-color: #f2f2f2;
        }
        tr:hover {
            background-color: #f5f5f5;
        }
        .action-links a {
            margin-right: 10px;
            text-decoration: none;
        }
        .edit-link {
            color: #2196F3;
        }
        .delete-link {
            color: #f44336;
        }
    </style>
</head>
<body>
    <h1>作者列表</h1>
    <a href="{% url 'author_create' %}" class="add-button">添加作者</a>
    
    {% if authors %}
        <table>
            <thead>
                <tr>
                    <th>ID</th>
                    <th>姓名</th>
                    <th>简介</th>
                    <th>出生日期</th>
                    <th>创建时间</th>
                    <th>更新时间</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {% for author in authors %}
                    <tr>
                        <td>{{ author.id }}</td>
                        <td>{{ author.name }}</td>
                        <td>{{ author.bio|truncatechars:50 }}</td>
                        <td>{{ author.birth_date|date:"Y-m-d"|default:"未设置" }}</td>
                        <td>{{ author.created_at|date:"Y-m-d H:i:s" }}</td>
                        <td>{{ author.updated_at|date:"Y-m-d H:i:s" }}</td>
                        <td class="action-links">
                            <a href="{% url 'author_detail' author.id %}" class="view-link">查看</a>
                            <a href="{% url 'author_update' author.id %}" class="edit-link">编辑</a>
                            <a href="{% url 'author_delete' author.id %}" class="delete-link">删除</a>
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    {% else %}
        <p>暂无作者信息，请添加新作者。</p>
    {% endif %}
</body>
</html>